package com.incar.chuxing.payAndShare;

import android.app.Activity;

import com.incar.chuxing.bean.ChargeResultEvent;
import com.incar.chuxing.bean.DepositCarResultEvent;
import com.incar.chuxing.bean.PaySuccessEvent;
import com.incar.chuxing.bean.WebPaySuccessEvent;

import org.greenrobot.eventbus.EventBus;


/**
 * Created by michal on 8/7.
 */
/*
* 统一处理支付的结果
* */
public class PayResult {
    /**
     * @param activity      微信是WXPayEntryActivity  支付宝是发起支付的Activity
     * @param payMethod     1微信  2支付宝 3个人账户
     * @param userPayType   0缴纳汽车保证金     2账户充值   3汽车订单支付 4违章支付H5
     * @param payResultCode 0成功  1失败
     */
    public void handlePayResult(Activity activity, int payMethod, int userPayType, int payResultCode) {
        switch (userPayType) {  //判断支付什么
            case 0://缴纳汽车保证金
                EventBus.getDefault().post(new DepositCarResultEvent(payResultCode, payMethod));
                break;
            case 2: //账户充值
                EventBus.getDefault().post(new ChargeResultEvent(payResultCode, payMethod));
                break;
            case 3: //汽车订单支付
                EventBus.getDefault().post(new PaySuccessEvent(payResultCode, payMethod));
                break;
            case 4: //违章支付H5,唤起原生的支付
                EventBus.getDefault().post(new WebPaySuccessEvent(payResultCode, payMethod));
                break;

        }

        //微信支付结束EXPayEntryActivity
        if (payMethod == 1) {
            activity.finish();
        }
    }

}
